package com.jingbian.cppccbackend.service.impl.user;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jingbian.cppccbackend.entity.News;
import com.jingbian.cppccbackend.entity.dto.NewsListDTO;
import com.jingbian.cppccbackend.mapper.user.NewsMapper;
import com.jingbian.cppccbackend.service.user.INewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 新闻表，用于存储新闻信息 服务实现类
 * </p>
 *
 * @author pum
 * @since 2025-03-03
 */
@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements INewsService {
  @Autowired
  private NewsMapper newsMapper;

  @Override
  public PageInfo<News> getNewList(NewsListDTO newsListDTO) {
    PageHelper.startPage(newsListDTO.getPageNum(), newsListDTO.getPageSize());
    List<News> list = newsMapper.getNewsList(newsListDTO);
    return new PageInfo<>(list);
  }

  @Override
  public News getNewsDetail(Integer nid) {
    return newsMapper.selectById(nid);
  }
}
